
from appium import webdriver
import time,traceback

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '8.1.0'
desired_caps['deviceName'] = 'test'
# desired_caps['app'] = r'f:\apk\duoduo.apk'
desired_caps['appPackage'] = 'com.ibox.calculators'
desired_caps['appActivity'] = '.SplashActivity'
desired_caps['unicodeKeyboard']  = True
desired_caps['noReset'] = True
desired_caps['newCommandTimeout'] = 6000
#启动Remote RPC
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.implicitly_wait(10)

num3=driver.find_element_by_xpath("//*[@resource-id='com.ibox.calculators:id/digit3']").click()
puls=driver.find_element_by_xpath('//*[@ resource-id="com.ibox.calculators:id/plus"]').click()
num9=driver.find_element_by_xpath("//*[@resource-id='com.ibox.calculators:id/digit9']").click()
equal=driver.find_element_by_xpath('//*[@resource-id="com.ibox.calculators:id/equal"]').click()
mul=driver.find_element_by_xpath('//*[@ resource-id="com.ibox.calculators:id/mul"]').click()
num5=driver.find_element_by_xpath("//*[@resource-id='com.ibox.calculators:id/digit5']").click()
equal=driver.find_element_by_xpath('//*[@resource-id="com.ibox.calculators:id/equal"]').click()


tags='//*[@resource-id="com.ibox.calculators:id/cv"]//android.widget.TextView[2]'
nums=driver.find_element_by_xpath(tags).text
nums=int(nums)
print(nums)
if nums == 60:
    print( 'test pass')
else:
    print('test fail')
